<template>
	<view class="progress">
		<u-input ref="input" :prefixIconStyle="{fontSize:'24px'}" prefixIcon="scan" :focus="focus" v-model.trim="barcode"
			placeholder="点击我扫码" @confirm="onConfirm" />
	</view>
</template>

<script>
	export default {
		name: "cx-scan-input",
		data() {
			return {
				focus: true,
				barcode: ''
			}
		},
		methods: {
			onConfirm() {
				this.$emit("on-confirm", this.barcode)
				this.barcode = ""
				this.focus = false
				this.$nextTick(_ => {
					this.focus = true
				})
			}
		}
	}
</script>

<style scoped>
	.progress {
		background: #fff;
		padding: 20rpx;
		box-shadow: 0 6px 6px rgba(0, 0, 0, .1);
		display: flex;
		align-items: center;
	}
</style>
